<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.java.service.*,java.util.*,com.java.model.UserSession,com.java.util.*"%>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<jsp:include page="common/header.jsp"></jsp:include>
<%
	UserSession usersession = (UserSession)session.getAttribute("user");
	String ent_id 			= (String)session.getAttribute("ent_id");
	
	String connGroup 	= "";
	String user_id 		= "";
	if(usersession!=null){
		connGroup 	= CmmUtil.nvl(usersession.getConnGroup(),"0");
		user_id 	= CmmUtil.nvl(usersession.getUser_id(),"");
	}
	String keyword_gb 	= CmmUtil.nvl(request.getParameter("search_gb"),"");
	String keyword 		= CmmUtil.nvl(request.getParameter("search_word"),"");
	String keyword2 	= CmmUtil.nvl(request.getParameter("search_word"),"");
	String line_number	= CmmUtil.nvl(request.getParameter("line_number"),"10");
	
	System.out.println("keyword  " + keyword);

	//페이징 처리 Start
 	//페이지 표시정보 받기 혹은 검색입력창
 	String curr_page = request.getParameter("curr_page");
 	if (curr_page == null || curr_page.equals(""))
 		curr_page = "1";
 	String one_page = request.getParameter("one_page");
 	if (one_page == null || one_page.equals(""))
 		one_page = "10";
 	String one_group = request.getParameter("one_group");
 	if (one_group == null || one_group.equals(""))
 		one_group = "10";
 	
 	String total_count = CmmUtil.nvl(request.getParameter("total_count"),"0");
 	
 	//페이징 처리 End
 	
 	if(keyword_gb.equals("3")){
 		keyword = Crypto.EncodeBySType(keyword);
 	}
 	
	HashMap map = new HashMap();
	HashMap map1 = null;
	ArrayList list = new ArrayList();
	CommonDaoService commonservice = new CommonDaoService("Com0101lp03Dao");
	map.put("connGroup",connGroup);
	map.put("user_id",user_id);
	map.put("ent_id",ent_id);
	map.put("member_gb","");
	map.put("keyword_gb",keyword_gb);
	map.put("keyword",keyword);
	map.put("quit_yn","N");
	map.put("page_row",line_number);
	map.put("total_row",total_count);
	map.put("page_no",curr_page);
	
	list = (ArrayList)commonservice.commonDaoMethod(map);
	

	if(list != null){
		if(list.size() > 0){
			total_count = (String)((HashMap)list.get(0)).get("total_row");
			System.out.println("total_count " + total_count);
		}
	}
	
	if(list.size() == 0){
		total_count = "0";
	}
	
	//리스트에 뿌릴 사용자 정보
	String id 				="";
	String norm_phone_no 	="";
	String cell_phone_no 	="";
	String last_conn_dt		="";
	String uni_id			="";
	String login_nm			="";
	String rownum			="";
	
%>
<script>
function search(){
	var frm = document.mainfrm;
	frm.action = "/jsp/com0101l_p03.jsp";
	frm.target="_self";
	frm.curr_page.value ="1";
	frm.total_count.value=0;
	frm.submit();
}

// 페이지 번호를 눌렸을때.
function go_page(page){
	var frm = document.mainfrm;
	frm.curr_page.value = page ;			
	frm.total_count.value = "<%=total_count%>";
	frm.search_word.value = "<%=keyword%>";
	frm.action = "/jsp/com0101l_p03.jsp";
	frm.target="_self";
	frm.submit();
}

//설정 팝업
function viewPop1(uni_id){
	var frm = document.mainfrm;
	open("","viewPop","width=530,height=300,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no ");
	frm.uni_id.value= uni_id;
	frm.action = "/jsp/pop/com0101l_p03_pop01.jsp";
	frm.target = "viewPop";
	frm.method = "post";
	frm.submit();
}

//수강이력 팝업
function viewPop2(uni_id,login_nm){
	var frm = document.mainfrm;
	open("","viewPop","width=530,height=400,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes ");
	frm.uni_id.value= uni_id;
	frm.login_nm.value = login_nm;
	frm.action = "/jsp/pop/com0101l_p03_pop02.jsp";
	frm.target = "viewPop";
	frm.method = "post";
	frm.submit();
}

//SMS발송 팝업
function smsPop(){
	var frm = document.mainfrm;
	var checkboxObject = document.getElementsByName("checkbox");
	var cLength =  checkboxObject.length;
	var submitOk = "";
	
	for(var i=0; i< cLength; i++){
		if(checkboxObject[i].checked == true){
			submitOk ="true";
		} 		
	}
	if(submitOk == ""){
		alert("SMS를 발송할 회원을 선택해주세요");
		return;
	}
	
	open("","viewPop","width=530,height=400,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes ");
	frm.action = "/jsp/pop/smsPop.jsp";
	frm.target = "viewPop";
	frm.method = "post";
	frm.submit();
}

//엑셀다운로드
function excel_down(){
	var frm = document.mainfrm;
	frm.action = "/jsp/com0101l_p03_excel.jsp";
	frm.target="_blank";
	frm.method = "post";
	frm.submit();	
}

//엔터키 
function checkkeycode(t){
	if ( event.keyCode == 13 ) {
		search();
	} 
}

//회원등록
function member_insert(){
	location.href ="com0101l_p04.jsp";
}

function go_detail(uni_id){
	var frm = document.mainfrm;
	frm.uni_id.value = uni_id;
	frm.target = "_self";
	frm.action = "/jsp/com0101l_p04.jsp";	
	frm.method = "post";
	frm.submit();	
}
</script>
<body>
<table width="992" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td>
    <!--top -->
    <jsp:include page="common/top_menu.jsp"></jsp:include> 
    <!-- //top -->
    <!-- contents area -->
<form name="mainfrm" method="post">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
<input type="hidden" name="uni_id" value="">
<input type="hidden" name="ent_id" value="<%=ent_id %>">

<!-- SMS발송(popup) 으로 넘길 인자 -->
<input type="hidden" name="cell_phone_no" value="<%=cell_phone_no%>">
<input type="hidden" name="login_nm" value="<%=login_nm %>">
<input type="hidden" name="uni_id2" value="<%=uni_id %>">
<input type="hidden" name="user_id" value="<%=id %>">
	<!-- //SMS발송(popup) 으로 넘길 인자 -->

  <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="180" valign="top">
    	<jsp:include page="left/com0101l_p05.jsp"></jsp:include>
    </td>
    <td width="21" valign="top">&nbsp;</td>
    <td valign="top">
    	 <table width="790px"  border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td style="font-size:14px; color:#3b70a2; font-weight:bold; border-bottom:2px solid #c8c8c8; padding:0 0 5px 0;" align="left"><img src="/images/sub_icon1.jpg"  alt="" border="0">&nbsp;회원관리</td>
             </tr>
        </table>
         <table width="790px" border="0" cellpadding="0" cellspacing="0" style="margin:20px 0 0 0">
           <tr>
             <td align="left"><select id="_number" name="line_number" class="line_number">
                 <option value="5" <%if(line_number.equals("5")){%>selected<%}%>>5줄</option>
                 <option value="10" <%if(line_number.equals("10")){%>selected<%}%>>10줄</option>
                 <option value="15" <%if(line_number.equals("15")){%>selected<%}%>>15줄</option>
                 <option value="20" <%if(line_number.equals("20")){%>selected<%}%>>20줄</option>
               </select>
             </td>
             <td align="right"><img src="/images/icon_search.gif" align="absmiddle" />&nbsp;검색&nbsp;&nbsp;
             
             	<select name="search_gb">
                 <!-- option value="1" <%if(keyword_gb.equals("1")){%>selected<%}%>>회사</option-->
                 <option value="2" <%if(keyword_gb.equals("2")){%>selected<%}%>>이름</option>
                 <option value="3" <%if(keyword_gb.equals("3")){%>selected<%}%>>ID</option>
               </select>
           		<input type="text" name="search_word" value="<%=keyword2 %>" class="textbox" onKeypress="checkkeycode(event);" required="required" hname="검색어" />
                <a href="javascript:search()"><img src="/images/bt_search1.gif" align="absmiddle"/></a>
             </td>
           </tr>
         </table>
         <table width="790px" border="0" cellspacing="0" class="bbs_property" summary="" style="font-size:11px; margin:13px 0 20px 0;">
            <caption></caption>
            <thead>
             <tr>
              <th>No</th>
              <th>성명</th>
              <th>아이디</th>
              <th>일반전화</th>
              <th>휴대전화</th>
              <th>최근 접속일</th>
              <th>설정</th>
              <th>수강이력</th>
              <!-- th>선택</th -->
             </tr>
            </thead>
            <tbody>
           <%if(list != null && list.size() > 0){%>
            <%for(int i=0; i<list.size(); i++){
            	map1 			= (HashMap)list.get(i);
            	id 				= Crypto.DecodeBySType((String)map1.get("login_id"));
            	cell_phone_no 	= CmmUtil.nvl((String)map1.get("cell_phone_no"),"--");
            	norm_phone_no 	= CmmUtil.nvl((String)map1.get("norm_phone_no"),"--");
            	last_conn_dt	= CmmUtil.nvl((String)map1.get("last_conn_dt") ,"--");
            	uni_id			= CmmUtil.nvl((String)map1.get("uni_id") ,"");
            	login_nm		= CmmUtil.nvl((String)map1.get("login_nm") ,"");
            	rownum			= CmmUtil.nvl((String)map1.get("rownum") ,"");
			%>
	
             <tr>
              <td scope="row" class="ranking"><%=rownum %></td>
              <td style="background:#ebf7d4;"><a href="javascript:go_detail('<%=uni_id%>')"><%=login_nm %></a></td>
              <td><%=id %></td>
              <td><%=norm_phone_no %></td>
              <td><%=cell_phone_no %></td>
              <td style="background:#e8f2fe;"><%=last_conn_dt %></td>
              <td><img src="/images/hrd_icon3.gif" alt="" onclick="javascript:viewPop1('<%=uni_id %>');" style="cursor:hand" border="0"/></td>
              <td><input name="Button" type="button" class="btn_blue_s_w45" id="button" onclick="javascript:viewPop2('<%=uni_id %>','<%=login_nm %>');" value="View" /></td>
              <!-- td><input type="checkbox" name = "checkbox" id="checkbox" onclick="" value="<%=i%>"></td -->
             </tr>
             <%} %>
            <%}else{ %>
             <tr>
             	<td colspan="9">데이터가 없습니다</td>
             </tr>
            <%} %>
            </tbody>
            </table>
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
             <tr>
  
                <td align="right">
                	<table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="170px" style="padding:0 0 8px 0; font-weight:bold; color:#FF6600;" align="left">총 회원: <%=(ent_id.equals("128"))?Integer.parseInt(total_count)+6332 : total_count %> 명</td>
                        <!-- 페이징 -->
                       <common:pagelistnew currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=one_page%>" oneGroup="<%=one_group%>"/>
                        <!-- //페이징 -->
                      </tr>
                    </table>
           	  		<table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="84px" align="left">
                            <table border="0" cellpadding="0" cellspacing="0" >
                                <tr>
                                  <td><!-- a href="javascript:smsPop()"><img src="/images/btn_sms_btn.gif"></a></td -->
                                   <td align="left" style="padding:0 0 0 3px;"><a href="javascript:excel_down()"><img src="/images/btn_save_excel2.gif"/></a></td>
                                </tr>
                            </table>
                         </td>
                        <td align="right"><input name="button2" type="button" class="btn_orange_b_w47" value="등록" onClick="javascript:member_insert()"/></td>
                        </tr>
                    </table> 
               </td>
             </tr>
           </table>
    </td>
    </tr>
	</table>
</form>
   
    <jsp:include page="common/footer.jsp"></jsp:include>
	</td>
  </tr>
</table>
<iframe name='hide_src'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
</body>
</html>
